﻿using System.ComponentModel.DataAnnotations;
using StudentManagementSystem.Dtos;

namespace StudentManagementSystem.ValidationAttributes
{
    public class EmployeeNoMustDifferentFromFirstNameAttribute:ValidationAttribute
    {
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var instace = (EmployeeAddOrUpdateDto)validationContext.ObjectInstance;
            if (instace.EmployeeNo == instace.FirstName)
            {
                return new ValidationResult("员工编号不可以等于名", 
                    new[] {nameof(EmployeeAddOrUpdateDto) });
            }


            return ValidationResult.Success;
        }
}
}
